package com.qf.ability.test.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.util.Date;

@Data
@Document(indexName = "goods_index", shards = 1, replicas = 0)
public class Goods {

    @Id
    private Integer id;

    /**
     * @MultiField 表示一个字段，使用多个字段类型
     * <p>
     * mainField - 表示当前字段的主类型，类型名称就是 title
     * otherFields - 表示当前字段的副类型，类型名称就是 title.a  title.b
     */
    @MultiField(
            mainField = @Field(type = FieldType.Text, index = true, store = false, analyzer = "ik_max_word"),
            otherFields = {
                    @InnerField(suffix = "pinyin", type = FieldType.Text, analyzer = "pinyin"),
                    @InnerField(suffix = "keyword", type = FieldType.Keyword)
            }
    )
    private String title;

    @Field(type = FieldType.Double)
    private Double price;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String info;

    @Field(type = FieldType.Keyword, index = false)
    private String image;

    //    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    @Field(type = FieldType.Long)
    private Date creataTime;
}